import constants
from views import CacheListAPIView
from .models import Nav,Banner
from .serializers import NavModelSerializer,BannerModelSerializer


class NavHeaderListAPIView(CacheListAPIView):
    queryset = Nav.objects.filter(position=constants.NAV_header_POSITION, is_show=True, is_delete=False).order_by(
        'orders', '-id')[:constants.NAV_header_SIZE]
    serializer_class = NavModelSerializer


class NavFooterListAPIView(CacheListAPIView):
    queryset = Nav.objects.filter(position=constants.NAV_footer_POSITION, is_show=True, is_delete=False).order_by(
        'orders', '-id')[:constants.NAV_footer_SIZE]
    serializer_class = NavModelSerializer


class BannerListAPIView(CacheListAPIView):
    """轮播广告视图"""
    queryset = Banner.objects.filter(is_show=True, is_delete=False).order_by("orders", "-id")[:constants.Banner_SIZE]
    serializer_class = BannerModelSerializer

